package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: aulme
 * Date: 05/07/2013
 * Time: 10:53
 * To change this template use File | Settings | File Templates.
 */
public class Movie {
    private final String name;
    private final String director;
    private final int rating;
    private final int year;

    public String getName() {
        return name;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        return rating;
    }

    public int getYear() {
        return year;
    }

    public Movie(String name, String director, int year, int rating) {
        if (rating > 10 || rating < 0) {
            throw new IllegalArgumentException("The rating is out of allowed range");
        }

        this.name = name;
        this.director = director;
        this.year = year;
        this.rating = rating;
    }

    public Movie(String name, String director, int year) {
        this(name, director, year, 0);
    }

    public String getFormattedRating() {
        return this.rating == 0 ? "N/A" : String.valueOf(this.rating);
    }
}
